/*
 * @Author: Laputa
 * @Version: V0.0
 * @Date: 2023-05-30 15:44:54
 * @LastEditors: Laputa
 * @LastEditTime: 2023-09-11 14:07:31
 * @Description:
 *
 * Copyright (c) 2023 by Levetop, All Rights Reserved.
 */

#ifndef _TYPE_H
#define _TYPE_H
#include  "stdbool.h"

typedef unsigned int Uint32;
typedef unsigned short int Uint16;
typedef unsigned char Uint8;

typedef unsigned long long UINT64;
typedef unsigned int UINT32;
typedef unsigned short int UINT16;
typedef unsigned char UINT8;

typedef signed int INT32;
typedef signed short int INT16;
typedef signed char INT8;

typedef unsigned int u32;
typedef unsigned short int u16;
typedef unsigned char u8;

typedef unsigned long long int uint64_t;
typedef unsigned long int uint32_t;
typedef unsigned short int uint16_t;
typedef unsigned char uint8_t;

typedef signed long long int int64_t;
typedef signed long int int32_t;
typedef signed short int int16_t;
typedef signed char int8_t;

#define     __I     volatile const            /*!< defines 'read only' permissions */
#define     __O     volatile                  /*!< defines 'write only' permissions*/
#define     __IO    volatile                  /*!< defines 'read / write' permissions*/

typedef enum
{
    Reset = 0U,
    Set = 1U
} BitStatus, FlagStatus, ITStatus;

typedef enum
{
    Disable = 0U,
    Enable = 1U
} FunctionState;

typedef enum
{
    OK = 0U,
    ERROR = 1U
} ResultStatus;

#define IO_READ8(p)      		(*(volatile Uint8 *)(p))
#define IO_WRITE8(p,c)   		(*((volatile Uint8 *)(p)) = ((Uint8)(c)))

#define IO_READ16(p)     		(*(volatile Uint16 *)(p))
#define IO_WRITE16(p,v)  		(*((volatile Uint16 *)(p)) = (Uint16)(v))

#define IO_READ32(p)     		(*(volatile Uint32 *)(p))
#define IO_WRITE32(p,v)  		(*((volatile Uint32 *)(p)) = (Uint32)(v))

#define Bit_Shift(bit)      (1 << (bit))
#define Bit_Set(reg, bit)   ((reg) |= (bit))
#define Bit_Clear(reg, bit) ((reg) &= ~(bit))
#define Bit_Read(reg, bit)  ((reg)&(bit))
#define set_bit(BitNumber,Register)        (Register |=(1<<BitNumber))
#define clr_bit(BitNumber,Register)        (Register &=~(1<<BitNumber))
#define check_bit(BitNumber,Register)        (Register & (1<<BitNumber))
#endif
